package com.cloud.service.impl;


import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cloud.domian.Order;
import com.cloud.domian.Stock;
import com.cloud.mapper.OrderMapper;
import com.cloud.service.IOrderService;
import com.cloud.service.IStockService;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.extern.slf4j.Slf4j;


import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;


/**
 * @Description: 订单表
 * @Author: jeecg-boot
 * @Date:   2022-05-13
 * @Version: V1.0
 */
@Service
@Slf4j
@DS("order")
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements IOrderService {

    @Resource
    private IStockService iStockService;

    @Override
    public void createOrder(Long productId, Long productSpecs) {
        Order order = new Order();
        order.setOrderNumber("HX9786786");
        baseMapper.insert(order);

        Stock stock = iStockService.getById(12L);
        stock.setProductNum(stock.getProductNum() - 1);
        iStockService.updateById(stock);
        System.out.println();
        int a = 1/0;
    }
}
